import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provide/provide.dart';
import 'package:uitest/page/details_page/detail_top_area.dart';
import 'package:uitest/page/details_page/details_bottom.dart';
import 'package:uitest/page/details_page/details_explain.dart';
import 'package:uitest/page/details_page/details_tabbar.dart';
import 'package:uitest/page/details_page/details_web.dart';
import 'package:uitest/provide/details_info.dart';

class DetailsPage extends StatelessWidget{
  final String goodsId;
  DetailsPage(this.goodsId);
  @override
  Widget build(BuildContext context) {

  return Scaffold(
      appBar: AppBar(
        leading: IconButton(
          icon: Icon(Icons.arrow_back),
          onPressed: (){
            Navigator.pop(context);
          },
        ),
        title: Text('详情页'),
      ),
      body: FutureBuilder(
        future: _getBackInfo(context),
        builder: (context,snapshot){
          if (snapshot.hasData) {
            return SafeArea(
                child: Stack(
                children: <Widget>[
                   Container(
                     padding: EdgeInsets.only(left: 0,right: 0,top: 0,bottom: 50),
                     child: ListView(
                       children: <Widget>[
                        DetailsTopArea(),
                        DetailsExplain(),
                        DetailsTabbar(),
                        DetailsWeb(),
                       ],
                     ),
                   ),
                  Positioned(
                    bottom:0, // 安全区域 
                    left: 0,
                    child: DetailsBottom(),
                  )
                ],
              ),
            );
          } else {
            return Text('加载中');
          }
        }
      ),
    );
  }

  Future _getBackInfo(BuildContext context) async {
    await Provide.value<DetailsInfoProvide>(context).getGoodsInfo(goodsId);
    return '完成加载';
  }
}